import express from 'express'
const router = express.Router();
import { body } from 'express-validator';
import {login} from '../services/userService'

// 登录/注册校验
const vaildator = [
  body('username').isString().withMessage('用户名类型错误'),
  body('password').isString().withMessage('密码类型错误')
]

// 时间日志
router.use(function timeLog (req, res, next) {
  console.log('Time: ', Date.now())
  next()
})

// 用户登录路由
router.post('/login', vaildator, login)

export default router
